package me.miencraft.plugin.superlobby.item;

import lombok.Getter;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

/**
 * @author langle__
 * @version 1.0
 */
@Getter
public abstract class CustomItem {

    @NotNull private final ItemProperties properties;

    public CustomItem(@NotNull ItemProperties properties) {
        this.properties = properties;
    }

    public abstract void onItemUse(Player player);

    public boolean validate(ItemProperties properties) {
        return this.properties.validate(properties);
    }

    public boolean validate(ItemStack item) {
        return this.properties.validate(item);
    }

    public boolean validate(CustomItem item) {
        return this.properties.validate(item);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CustomItem that = (CustomItem) o;
        return Objects.equals(properties, that.properties);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(properties);
    }

    public ItemStack toItemStack() {
        return properties.toItemStack();
    }

}
